<?php 
/**
* teacher 学生管理
*/
class Teacher_knowledge_point extends CI_Controller
{
	
	function __construct()
	{
		parent::__construct();
		//登陆状态检测
		if(!$this->session->userdata('user_in'))
			redirect('home');
		//权限检测
		if($this->session->userdata('role_id') != 2)
			redirect('home');
	}

	/**
	 * student管理的主界面
	 * @return [type]
	 */
	function index($offset=0)
	{
		$data['title']='知识点查找';
		$this->load->model('knowledge_point_model');

		$this->load->library('pagination');

		$config['base_url'] = site_url().'/teacher_knowledge_point/index';
		$config['total_rows'] = $this->knowledge_point_model->count_all();
		$config['per_page'] = 10; 
		$config['first_link'] = '首页';
		$config['last_link'] = '尾页';
		$config['num_links'] = 5;
		$this->pagination->initialize($config); 

		if(!is_numeric($offset))
			$this->load->view('error');
		$offset=intval($offset);
		$data['knowledge_points']=$this->knowledge_point_model->get_all_knowledge_points_by_offset($config['per_page'],$offset);
		$data['knowledge_points_all']=$this->knowledge_point_model->get_all_with_test_point();
		$this->load->view('teacher_knowledge_point/index',$data);
	}

	function check($id)
	{
		$this->load->model('knowledge_point_model');
		$this->load->model('test_point_model');
		$this->load->model('question_model');
		//var_dump($id);
		$knowledge_point = $this->knowledge_point_model->get_by_id($id);
		//var_dump($knowledge_point);
		$test_point = $this->test_point_model->get_by_id($knowledge_point['test_point_id']);
		//var_dump($test_point);
		$questions = $this->question_model->get_by_knowledge_point($id);
		//var_dump($questions);

		$data['title']='知识点详情';
		$data['knowledge_point'] = $knowledge_point;
		$data['test_point'] = $test_point;
		$data['questions'] = $questions;
		$this->load->view('teacher_knowledge_point/check',$data);
	}

}